package cn.com.dcsgo.springcloudstudy.payment.service.impl;

import cn.com.dcsgo.springcloudstudy.commons.pojo.Payment;
import cn.com.dcsgo.springcloudstudy.payment.dao.PaymentDao;
import cn.com.dcsgo.springcloudstudy.payment.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author DCSGO
 * @version 1.0
 */
@Service
public class PaymentServiceImpl implements PaymentService {
    @Autowired
    PaymentDao paymentDao;

    @Override
    public long create(Payment payment) {
        int affectedRows = paymentDao.create(payment);
        if (affectedRows == 0) {
            throw new RuntimeException("插入失败");
        }
        return payment.getId();
    }

    @Override
    public Payment queryById(long id) {
        return paymentDao.queryById(id);
    }
}
